import type { Meta, StoryObj } from '@storybook/vue3-vite';

import { fn } from 'storybook/test';

import CodeEditor from './index.vue';
import { MODE } from './typing';

const meta: Meta<typeof CodeEditor> = {
  title: 'text/代码编辑器',
  component: CodeEditor,
  tags: ['autodocs'],
  argTypes: {
    modelValue: {
      control: 'text',
      description: '代码编辑器的内容'
    },
    language: {
      control: 'select',
      options: Object.values(MODE).filter(v => typeof v === 'string'),
      description: '代码语言',
    },
    showGutter: {
      control: 'boolean',
      description: '是否显示行号'
    },
    readOnly: {
      control: 'boolean',
      description: '是否只读模式'
    },
  },
  args: {
    modelValue: '',
    language: 'javascript',
    showGutter: true,
    readOnly: false,
  }

} satisfies Meta<typeof CodeEditor>;

export default meta;
type Story = StoryObj<typeof CodeEditor>;

export const Basic: Story = {
  name: '基础用法',
  args: {
    ...meta.args,
    modelValue: 'Hello, World!',
  },
};

export const Json: Story = {
  name: 'json代码',
  args: {
    ...meta.args,
    language: 'json',
    modelValue: `{"version": "9.99.99", "data": [1, 2, 3]}`,
  },
};

